SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
1.6 KB · 24 lines tsx
Raw Blame History
1import { ImageResponse } from 'next/og';2import { Fallback, Wallpaper } from '@/components/brand/og';3import { fmtMemory } from '@/components/hardware/hardware-bits';4import { api, intel, safe } from '@/lib/api';5import { fmtInt, num } from '@/lib/format';6import { SITE_NAME } from '@/lib/site';78export const runtime = 'nodejs';9export const alt = `Hardware on ${SITE_NAME}`;10export const size = { width: 1200, height: 630 };11export const contentType = 'image/png';1213export default async function HardwareOgImage({ params }: { params: Promise<{ slug: string }> }) {14  const { slug } = await params;15  const [d, fit] = await Promise.all([safe(api.entityOfType('hardware', slug)), safe(intel.hardwareSlugFit(slug, { limit: 1 }))]);16  if (!d || d.entity_type !== 'hardware') return new ImageResponse(<Fallback label="Hardware" />, { ...size });17  const a = d.attributes ?? {};18  const counters: [string, string][] = [['Memory', fmtMemory(a.memory_gb)]];19  if (num(a.memory_bandwidth_gbs) !== null) counters.push(['Bandwidth', `${fmtInt(a.memory_bandwidth_gbs)} GB/s`]);20  if (num(a.tdp_watts) !== null) counters.push(['TDP', `${fmtInt(a.tdp_watts)} W`]);21  if (fit) counters.push(['Fit @4bit (est.)', `${fmtInt(fit.counts.fits)} / ${fmtInt(fit.counts.evaluated)}`]);22  return new ImageResponse(<Wallpaper eyebrow={typeof a.manufacturer === 'string' ? `Hardware · ${a.manufacturer}` : 'Hardware'} title={d.name} subtitle="Published specifications with sources, and the models estimated to fit at 4-bit, 8-bit and fp16." counters={counters} footer={`www.ai-atlas.co/hardware/${slug}`} markPx={220} />, { ...size });23}24